package com.cgnpc.scp.todo.controller;

import cn.com.cgnpc.aep.bizcenter.appcenter.sdk.result.ApiResult;
import com.cgnpc.cud.annotation.OperatorType;
import com.cgnpc.cud.annotation.UBA;
import com.cgnpc.cud.core.domain.AjaxResult;
import com.cgnpc.scp.common.utils.AjaxResultUtil;
import com.cgnpc.scp.todo.service.AueTodoService;
import com.cgnpc.scp.todo.util.QueryTaskParams;
import com.cgnpc.scp.todo.util.TaskTotalParams;
import net.bytebuddy.asm.Advice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/******************************
 * 用途说明: 统一待办
 * 作者姓名: chenshijie
 * 创建时间: 2020/10/15 22:39
 ******************************/
@RestController
@RequestMapping("/scp/aue/todo")
public class AueTodoController {

    private static final Logger LOGGER = LoggerFactory.getLogger(AueTodoController.class);

    @Autowired
    private MessageSource messageSource;

    @Autowired
    private AueTodoService aueTodoService;

    /**********************************
     * 用途说明: 获取应用任务总条数
     * 参数说明 taskTotalParams
     * 返回值说明:
     ***********************************/
    @PostMapping("/queryTaskTotalByApps")
//    @UBA(module = "统一待办",action = "获取应用任务总条数",channel = OperatorType.Button)
    public AjaxResult queryTaskTotalByApps(HttpServletRequest request) {
        try {
            ApiResult apiResult = aueTodoService.queryTaskTotalByApps();
            return AjaxResultUtil.createI18nDefaultSuccess(request,messageSource,apiResult);
        } catch (Exception e) {
            LOGGER.error("AueTodoController queryTaskTotalByApps error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }

    /**********************************
     * 用途说明: 获取待办
     * 参数说明 queryTaskParams
     * 返回值说明:
     ***********************************/
    @PostMapping("/queryTask")
//    @UBA(module = "统一待办",action = "获取待办",channel = OperatorType.Button)
    public AjaxResult queryTask(HttpServletRequest request, @RequestBody Map map) {
        try {
            ApiResult apiResult = aueTodoService.queryTask(map);
            return AjaxResultUtil.createI18nDefaultSuccess(request,messageSource,apiResult);
        } catch (Exception e) {
            LOGGER.error("AueTodoController queryTaskTotalByApps error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }

}
